package com.bdqn.controller;

import com.bdqn.pojo.Account;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Author 27435
 * @Date 2024/12/3016:49
 * @Version 1.0
 */

@Controller
public class HelloController {

    @RequestMapping("/hello")
    public ModelAndView sayHello(){
        ModelAndView mv = new ModelAndView();
        // 设置视图
        mv.setViewName("hello");
        // 设置数据
        mv.addObject("msg", "success");
        Account account = new Account();
        account.setAcId(1);
        account.setAcName("tom");
        account.setBalance(1000);
        mv.addObject("account", account);
        return mv;
    }

    @RequestMapping("/f")
    public String forward1(){
        System.out.println("转发");
        return "forward:/WEB-INF/pages/for.jsp"; // 转发后视图解析器失败，所有需要写位置的转发路径
    }

    @RequestMapping("/r")
    public String redirect1(){
        System.out.println("重定向");
        return "redirect:re.jsp";
    }

}
